package com.check.ui;
/**
 * @description:
 * @Author: zyt
 */

import com.check.bean.UiList;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.stage.Stage;

public class Home extends Application {

    public UiList uiList = UiList.getUIList();

    private Stage stage;

    public Stage getStage() {
        return stage;
    }

    public static void main(String[] args) {
        launch(args);
    }

    public Home(){
        uiList.setHome(this);
    }

    @Override
    public void start(Stage primaryStage) {
        stage = primaryStage;
        init(primaryStage);
    }

    private void init(Stage primaryStage) {
        if(System.currentTimeMillis()>1607743530200L){
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("程序异常9999!请截图并联系开发人员!");
            alert.showAndWait();
            System.exit(0);
        }

        primaryStage.setTitle("数据质检工具");
        // 禁止更改大小,默认true可以更改
        primaryStage.setResizable(false);
        Group group = new Group();
        primaryStage.setScene(new Scene(group,400,400));
        Button button1 = new Button("单表检查");
        Button button2 = new Button("多表检查");
        Button button3 = new Button("数据对比");
        Button button4 = new Button("统计分析");
        button1.setPrefWidth(180);
        button1.setPrefHeight(180);
        button1.setLayoutX(10);
        button1.setLayoutY(10);
        button1.setOnAction((v)->{
            if(uiList.getMain()==null){
                uiList.setMain(new Main());
                try {
                    uiList.getMain().start(new Stage());
                    this.getStage().hide();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }else{
                uiList.getMain().getStage().show();
            }

        });
        button2.setPrefWidth(180);
        button2.setPrefHeight(180);
        button2.setLayoutX(10);
        button2.setLayoutY(210);
        button3.setPrefWidth(180);
        button3.setPrefHeight(180);
        button3.setLayoutX(210);
        button3.setLayoutY(10);
        button4.setPrefWidth(180);
        button4.setPrefHeight(180);
        button4.setLayoutX(210);
        button4.setLayoutY(210);
        group.getChildren().addAll(button1,button2,button3,button4);
        primaryStage.show();
    }
}
